import Vue from "vue";
import VueRouter from "vue-router";
import homeRouter from "../routerModules/home/homeRouter";
import {isToken} from '../utils/token'
Vue.use(VueRouter);

const routes = [
  // {
  //   path: "/",
  //   name: "Home",
  //   component: () => import("../views/Home/Homes.vue"),
  // },
  // {
  //   path: "/Home",
  //   redirect: "/",
  // },
  ...homeRouter,
  //Home页面的里 需要跳转的页面 开始
  // {
  //   path: "/Home/addContent",
  //   name: "addContent",
  //   component: () => import("../views/Home/homes/addContent.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/doctorHospital",
  //   name: "doctorHospital",
  //   component: () => import("../views/Home/homes/doctorHospital.vue"),
  //   //路由元信息 isShow 判断页面底部导航是否需要隐藏
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/medicalBeauty",
  //   name: "medicalBeauty",
  //   component: () => import("../views/Home/homes/medicalBeauty.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/newPeople",
  //   name: "newPeople",
  //   component: () => import("../views/Home/homes/newPeople.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/projectHiring",
  //   name: "projectHiring",
  //   component: () => import("../views/Home/homes/projectHiring.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/redPacket",
  //   name: "redPacket",
  //   component: () => import("../views/Home/homes/redPacket.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/searchCity",
  //   name: "searchCity",
  //   component: () => import("../views/Home/homes/searchCity.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/searchProject",
  //   name: "searchProject",
  //   component: () => import("../views/Home/homes/searchProject.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/yanjiuyuan",
  //   name: "yanjiuyuan",
  //   component: () => import("../views/Home/homes/yanjiuyuan.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // //Home页面的里 需要跳转的页面 结束

  // //Home的三级跳转页面 开始
  // {
  //   path: "/Home/redPacket/redRule",
  //   name: "redRule",
  //   component: () => import("../views/Home/homes/homesThree/redRule.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/yanjiuyuan/hotTopic",
  //   name: "hotTopic",
  //   component: () => import("../views/Home/homes/homesThree/hotTopic.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  // {
  //   path: "/Home/projectHiring/toView",
  //   name: "toView",
  //   component: () => import("../views/Home/homes/homesThree/toView.vue"),
  //   meta: {
  //     isShow: true,
  //   },
  // },
  //Home的三级跳转页面 结束

  //问医生跳转 开始
  {
    path: "/askDoctor",
    name: "askDoctor",
    component: () => import("../views/Doctors/askDoctor.vue"),
    meta: {
      needLogin: true,
    },
  },
  {
    path: "/askDoctor/inquiryCard",
    name: "inquiryCard",
    component: () => import("../views/Doctors/doctorsTwo/inquiryCard.vue"),
    meta: {
      isShow: true,
    },
  },
  {
    path: "/askDoctor/resume",
    name: "resume",
    component: () => import("../views/Doctors/doctorsTwo/resume.vue"),
    meta: {
      isShow: true,
    },
  },
  {
    path: "/askDoctor/consult",
    name: "consult",
    component: () => import("../views/Doctors/doctorsTwo/consult.vue"),
    meta: {
      isShow: true,
    },
  },
  //问医生跳转 结束

  {
    path: "/Zhengzhou",
    name: "Zhengzhou",
    component: () => import("../views/zhengzhou/Zhengzhou.vue"),
  },

  // 点击跳转

  //郑州里面的页面跳转 开始
  {
    path: "/Zhengzhou/maixian",
    name: "maixian",
    component: () => import("../views/zhengzhou/zhengzhous/maixian.vue"),
    meta: {
      isShow: true,
    },
  },
  //郑州里面的页面跳转 结束

  {
    path: "/New",
    name: "New",
    component: () => import("../views/News/New.vue"),
    meta: {
      needLogin: true,
    },
  },
  {
    path: "/Mine",
    name: "Mine",
    component: () => import("../views/Mine/Mine.vue"),
    meta: {
      needLogin: true,
    },
  },
];

const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  if (to.meta.needLogin) {
    if (isToken()) {
      next();
    } else {
      next("/phone");
    }
  } else {
    next();
  }
});

export default router;
